<script setup>

</script>

<template>
    <div>
        <el-card>
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="学生姓名">
                    <el-input v-model="form.studentName" style="width: 300px; margin-right: 80%;" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="性别">
                    <el-radio-group v-model="form.gender" style="width: 300px; margin-right: 80%;" size="mini">
                        <el-radio label="男"></el-radio>
                        <el-radio label="女"></el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="出生日期">
                    <el-date-picker v-model="form.birthdate" type="date" placeholder="选择日期" value-format='yyyy-MM-dd'
                        style="width: 300px; margin-right: 80%;" size="mini">
                    </el-date-picker>
                </el-form-item>
                <el-form-item label="联系电话">
                    <el-input v-model="form.cellphone" style="width: 300px; margin-right: 80%;" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="咨询校区">
                    <el-select v-model="school" placeholder="请选择" clearable size="mini" @change="choiceSchool()"
                        style="width: 300px; margin-right: 80%;">
                        <el-option v-for="item in schools" :key="item.id" :label="item.campusName" :value="item.campusName">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="招生来源">
                    <el-select v-model="studentSource" placeholder="请选择" clearable size="mini" @change="choiceSource()"
                        style="width: 300px; margin-right: 80%;" >
                        <el-option v-for="item in studentSources" :key="item.id" :label="item.source" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="跟踪状态">
                    <el-select v-model="form.state" placeholder="请选择状态" style="width: 300px; margin-right: 80%;"
                        size="mini">                                           
                        <el-option label="跟踪中" value="跟踪中"></el-option>
                        <el-option label="不在跟踪" value="不在跟踪"></el-option>
                        <el-option label="即将成单" value="即将成单"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="意向程度">
                    <el-select v-model="form.leveling" placeholder="请选择状态" style="width: 300px; margin-right: 80%;"
                        size="mini">
                        <el-option label="高" value="高"></el-option>
                        <el-option label="中" value="中"></el-option>
                        <el-option label="低" value="低"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="家长姓名">
                    <el-input v-model="form.parentsName" style="width: 300px; margin-right: 80%;" size="mini"></el-input>
                </el-form-item>
                <el-form-item label="所属关系">
                    <el-radio-group v-model="form.ownership" style="width: 300px; margin-right: 80%;" size="mini">
                        <el-radio label="父亲"></el-radio>
                        <el-radio label="母亲"></el-radio>
                        <el-radio label="其他"></el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="录入人">
                    <el-select v-model="teacher" placeholder="请选择" clearable size="mini" @change="choiceTeacher()"
                        style="width: 300px; margin-right: 80%;" >
                        <el-option v-for="item in teachers" :key="item.id" :label="item.name" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="录入校区">
                    <el-select v-model="school1" placeholder="请选择" clearable size="mini" @change="choiceSchool1()"
                        style="width: 300px; margin-right: 80%;">
                        <el-option v-for="item in schools1" :key="item.id" :label="item.campusName" :value="item.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-divider></el-divider>
                <el-form-item>
                    <el-button type="primary" @click="add()">提交</el-button>
                    <el-button>取消</el-button>
                </el-form-item>
            </el-form>
            
        </el-card>


    </div>
</template>
<script>
export default {
    data() {
        return {
            school: '',
            schools: [],
            school1: '',
            schools1: [],
            studentSource: '',
            studentSources: [],
            teacher:'',
            teachers:[],
            leveling:'',
            form: {
                studentName: '',
                gender:'',
                birthdate:'',
                cellphone:'',
                state:'',
                leveling:'',
                parentsName:'',
                ownership:''
            }
        }
    },
    methods: {
        choiceSchool: function () {
            console.log(this.school)
        },
        choiceSchool1: function () {
            console.log(this.school1)
        },
        choiceSource: function () {
            console.log(this.studentSource)
        },
        choiceTeacher: function () {
            console.log(this.teacher)
        },
        add() {
            let data = {
                studentName: this.form.studentName,
                gender: this.form.gender,
                birthdate: this.form.birthdate,
                cellphone: this.form.cellphone,
                campus: this.school,
                sourceId: this.studentSource,
                state: this.form.state,
                leveling: this.form.leveling,
                parentsName: this.form.parentsName,
                ownership: this.form.ownership,
                teacherId:this.teacher,
                schoolId:this.school1
            }
            console.log(data);
            this.$axios.post("/prospectiveStudent/insertPS", data).then(res => {
                console.log(res.data)
                this.$message.success("添加成功")
                this.$router.push("/prospectiveStudent")
            })
        },
    },
    mounted: function () {
        this.$axios.get("/dynamic/choiceSchool").then(res => {
            this.schools = res.data.data
            this.schools1 = res.data.data
        })
        this.$axios.post("/prospectiveStudent/findBySource").then(res => {
            this.studentSources = res.data.data
        })
        this.$axios.get("/prospectiveStudent/findByTeacher").then(res => {
            this.teachers = res.data.data
        })
    },
}
</script>
<style scoped></style>

